package atg.commerce.payment;

import java.util.List;

import atg.commerce.order.PaymentGroup;
import atg.nucleus.GenericService;
import atg.payment.tax.*;

public class MyTaxHandler extends GenericService implements TaxProcessor {

	@Override
	public TaxStatus calculateTax(TaxRequestInfo pTaxInfo) {
		/*  45*/        double taxableAmount = 0.0D;
		
		/*  47*/        if(isLoggingDebug())
		                {
		/*  48*/            for(int i = 0; i < pTaxInfo.getShippingDestinations().length; i++)
		                    {
		/*  49*/                ShippingDestination dest = pTaxInfo.getShippingDestinations()[i];
		/*  50*/                logDebug((new StringBuilder()).append("DUMMY TAX PROCESSOR taxing a GROUP with amount : ").append(dest.getTaxableItemAmount()).toString());
		/*  52*/                taxableAmount += dest.getTaxableItemAmount();
		                    }

		                }
		/*  56*/        if(isLoggingDebug())
		/*  57*/            logDebug((new StringBuilder()).append("taxable amount: ").append(taxableAmount).toString());
		/*  61*/        DummyTaxStatus ret = new DummyTaxStatus();
		/*  63*/        ret.setTransactionSuccess(true);
						if((pTaxInfo.getBillingAddress().getCountry()=="USA")||(pTaxInfo.getBillingAddress().getPostalCode()=="11111"))
						{
							ret.setAmount(pTaxInfo.getOrder().getPriceInfo().getAmount()*0.1);
						}
						else
						{
							ret.setAmount(pTaxInfo.getOrder().getPriceInfo().getAmount()*0.15);
						}
						
						
		/*  65*/        return ret;
	}

	@Override
	public TaxStatus[] calculateTaxByShipping(TaxRequestInfo pTaxInfo) {
		/*  79*/        DummyTaxStatus ret[] = new DummyTaxStatus[pTaxInfo.getShippingDestinations().length];
		/*  81*/        for(int i = 0; i < pTaxInfo.getShippingDestinations().length; i++)
		                {
		/*  82*/            if(isLoggingDebug())
		                    {
		/*  83*/                ShippingDestination dest = pTaxInfo.getShippingDestinations()[i];
		/*  84*/                logDebug((new StringBuilder()).append("DUMMY TAX PROCESSOR taxing a GROUP with amount : ").append(dest.getTaxableItemAmount()).toString());
		                    }
		/*  86*/            ret[i] = new DummyTaxStatus();
		/*  87*/            ret[i].setTransactionSuccess(true);
		ret[i].setAmount(pTaxInfo.getOrder().getPriceInfo().getAmount()*0.15);
		                }

		/*  90*/        return ret;
	}

}
